package com.szd.qiongyou20.home.adapter;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.szd.qiongyou20.R;
import com.szd.qiongyou20.home.bean.CityData;

import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by SZD on 2016/12/23.
 */

public class ListView_City_ReadMore_Adapter extends BaseAdapter {

    private Context mContext;
    private List<CityData.DataBean.MguideListsBean> mListsBeen;

    public ListView_City_ReadMore_Adapter(Context context, List<CityData.DataBean.MguideListsBean> listsBeen) {
        mContext = context;
        mListsBeen = listsBeen;
    }

    @Override
    public int getCount() {
        return mListsBeen.size();
    }

    @Override
    public Object getItem(int position) {
        return mListsBeen.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        if (convertView == null) {
            convertView = LayoutInflater.from(mContext).inflate(R.layout.item_city_read_more, null);
            holder = new ViewHolder(convertView);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }

        String mguide_photo = mListsBeen.get(position).getMguide_photo();
        String mguide_name = mListsBeen.get(position).getMguide_name();

        Log.i("=====", "getView: "+mguide_photo);

        Glide.with(mContext).load(mguide_photo).into(holder.mImageViewCityReadMore);
        holder.mTextViewCityReadMore.setText(mguide_name);
        return convertView;
    }

    static class ViewHolder {
        @Bind(R.id.imageView_city_read_more)
        ImageView mImageViewCityReadMore;
        @Bind(R.id.textView_city_read_more)
        TextView mTextViewCityReadMore;

        ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}
